package zhh.tangbao.system.utils;

import org.springframework.stereotype.Component;
import zhh.tangbao.user.vo.UserVo;

/**
 * @author 粥灰灰
 * @created 2022/10/1
 * @version 1.0
 * @Description 用于获取每次请求的用户参数，无需每个接口都加入Request作为传参来通过session获取，降低耦合度
 */
@Component
public class UserHolderUtil {
    private final ThreadLocal<UserVo> local = new ThreadLocal<>();

    public void setCurrentUser(UserVo user) {
        local.set(user);
    }

    public UserVo getCurrentUser() {
        return local.get();
    }
}
